/**
 * Created with IntelliJ IDEA.
 * Description:类的继承
 * User: LianBao
 * Date: 2024-03-01
 * Time: 12:50
 */

class Animal {
    String name;
    int age;

    static {
        System.out.println("Animal的静态代码块(static)");
    }

    {
        System.out.println("Animal的实例代码块");
    }

    public Animal(String name, int age) {
        System.out.println("Animal的构造方法");
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(name + "正在吃饭");
    }

    public void sleep() {
        System.out.println(name + "正在睡觉");
    }
}

class Dog extends Animal {

    static {
        System.out.println("Dog的静态代码块(static)");
    }

    {
        System.out.println("Dog的实例代码块");
    }

    public Dog(String name, int age) {
        super(name, age);
        System.out.println("Dog的构造方法");
    }


    public void Barks() {
        System.out.println(name + "正在汪汪叫");
    }

}

class Cat extends Animal {
    static {
        System.out.println("Dog的静态代码块(static)");
    }

    {
        System.out.println("Dog的实例代码块");
    }


    public Cat(String name, int age) {
        super(name, age);
        System.out.println("Cat的构造方法");
    }


    public void mew() {
        System.out.println(name + "正在喵喵喵");
    }

}

public class Test {

    public static void main(String[] args) {

        Dog d1 = new Dog("阿黄", 9);
        System.out.println("====================");
        Dog d2 = new Dog("小黑", 9);

    }

}
